`:top
The `!quadratic assignment problem`! (`!QAP`!) is one of the fundamental `F33f`_`[combinatorial optimization`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Combinatorial_optimization]`_`f problems in the branch of `F33f`_`[optimization`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Optimization_(mathematics)]`_`f or `F33f`_`[operations research`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Operations_research]`_`f in `F33f`_`[mathematics`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Mathematics]`_`f, from the category of the `F33f`_`[facilities location`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Optimal_facility_location]`_`f problems first introduced by Koopmans and Beckmann.`:cite-ref-1[`F5bf`_`[1`#cite-note-1]`_`f]
The problem models the following real-life problem:
There are a set of `*n`* facilities and a set of `*n`* locations. For each pair of locations, a `*distance`* is specified and for each pair of facilities a `*weight`* or `*flow`* is specified (e.g., the amount of supplies transported between the two facilities). The problem is to assign all facilities to different locations with the goal of minimizing the sum of the distances multiplied by the corresponding flows.
Intuitively, the cost function encourages facilities with high flows between each other to be placed close together.
The problem statement resembles that of the `F33f`_`[assignment problem`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Assignment_problem]`_`f, except that the `F33f`_`[cost function`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Loss_function]`_`f is expressed in terms of quadratic inequalities, hence the name.
>>Contents
• `F0af`_`[Formal mathematical definition`#formal-mathematical-definition]`_`f
• `F0af`_`[Computational complexity`#computational-complexity]`_`f
• `F0af`_`[Applications`#applications]`_`f
• `F0af`_`[See also`#see-also]`_`f
• `F0af`_`[References`#references]`_`f
• `F0af`_`[Other sources`#other-sources]`_`f
• `F0af`_`[External links`#external-links]`_`f
-─
>>Formal mathematical definition
The formal definition of the quadratic assignment problem is as follows:
Given two sets, `*P`* ("facilities") and `*L`* ("locations"), of equal size, together with a `F33f`_`[weight function`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Weight_function]`_`f `*w`* : `*P`* × `*P`* → `!`F33f`_`[R`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Real_number]`_`f`! and a distance function `*d`* : `*L`* × `*L`* → `!`F33f`_`[R`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Real_number]`_`f`!. Find the `F33f`_`[bijection`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Bijection]`_`f `*f`* : `*P`* → `*L`* ("assignment") such that the cost function:
∑ ∑ a , b ∈ ∈ P w ( a , b ) ⋅ ⋅ d ( f ( a ) , f ( b ) ) {\\displaystyle \\sum _{a,b\\in P}w(a,b)\\cdot d(f(a),f(b))}
is minimized.
Usually weight and distance functions are viewed as square real-valued `F33f`_`[matrices`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Matrix_(mathematics)]`_`f, so that the cost function is written down as:
∑ ∑ a , b ∈ ∈ P w a , b d f ( a ) , f ( b ) {\\displaystyle \\sum _{a,b\\in P}w_{a,b}d_{f(a),f(b)}}
In matrix notation:
min X ∈ ∈ Π Π n trace ( W X D T X T ) {\\displaystyle \\min _{X\\in \\Pi _{n}}\\operatorname {trace} (WXD^{T}X^{T})}
where Π Π n {\\displaystyle \\Pi _{n}} is the set of n × × n {\\displaystyle n\\times n} permutation matrices, W {\\displaystyle W} is the weight matrix and D {\\displaystyle D} is the distance matrix.
>>Computational complexity
The problem is `F33f`_`[NP-hard`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=NP-hard]`_`f, so there is no known `F33f`_`[algorithm`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Algorithm]`_`f for solving this problem in `F33f`_`[polynomial time`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Time_complexity]`_`f, and even small instances may require long computation time. It was also proven that the problem does not have an approximation algorithm running in polynomial time for any (constant) factor, unless P = NP.`:cite-ref-2[`F5bf`_`[2`#cite-note-2]`_`f] The `F33f`_`[travelling salesman problem`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Travelling_salesman_problem]`_`f (TSP) may be seen as a special case of QAP if one assumes that the flows connect all facilities only along a single ring, all flows have the same non-zero (constant) value and all distances are equal to the respective distances of the TSP instance. Many other problems of standard `F33f`_`[combinatorial optimization`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Combinatorial_optimization]`_`f problems may be written in this form.
>>Applications
In addition to the original plant location formulation, QAP is a mathematical model for the problem of placement of interconnected `F33f`_`[electronic components`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Electronic_component]`_`f onto a `F33f`_`[printed circuit board`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Printed_circuit_board]`_`f or on a `F33f`_`[microchip`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Integrated_circuit]`_`f, which is part of the `F33f`_`[place and route`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Place_and_route]`_`f stage of `F33f`_`[computer aided design`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Computer_aided_design]`_`f in the electronics industry.
The QAP has also been used to model the cost of character placement on a keyboard. In this case, the locations are keys on the keyboard and their pairwise distances correspond to the time required to press a given pair of keys. The facilities are characters and their weights are proportional to how often the given pair of characters occur in a text corpus. This type of QAP model was used in the design of the French keyboard standard (NF Z71-300).`:cite-ref-t142-3-0[`F5bf`_`[3`#cite-note-t142-3]`_`f]
>>See also
• `F33f`_`[Quadratic bottleneck assignment problem`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Quadratic_bottleneck_assignment_problem]`_`f
>>References
`:cite-note-1`!1.`! `F0af`_`[↑`#cite-ref-1]`_`f Koopmans TC, Beckmann M (1957). Assignment problems and the location of economic activities. Econometrica 25(1):53-76
`:cite-note-2`!2.`! `F0af`_`[↑`#cite-ref-2]`_`f `:citerefsahnigonzalez1976`aSahni, Sartaj; Gonzalez, Teofilo (July 1976). "P-Complete Approximation Problems". `*Journal of the ACM`*. `!23`! (3): 555–565. `F33f`_`[doi`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Doi_(identifier)]`_`f:10.1145/321958.321975. `F33f`_`[hdl`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Hdl_(identifier)]`_`f:10338.dmlcz/103883.
`:cite-note-t142-3`!3.`! `F0af`_`[↑`#cite-ref-t142-3-0]`_`f `:citerefjohnkarrenbauer2019`aJohn, Maximilian; Karrenbauer, Andreas (2019). "Dynamic Sparsification for Quadratic Assignment Problems". `*Mathematical Optimization Theory and Operations Research`* (PDF). Vol. 11548. Cham: Springer International Publishing. p. 232–246. `F33f`_`[doi`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Doi_(identifier)]`_`f:10.1007/978-3-030-22629-9_17. `F33f`_`[ISBN`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=ISBN_(identifier)]`_`f 978-3-030-22628-2.
>>Other sources
• `:citerefmichael-r-garey-and-david-s-johnson1979`a`F33f`_`[Michael R. Garey`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Michael_R._Garey]`_`f and `F33f`_`[David S. Johnson`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=David_S._Johnson]`_`f (1979). `F33f`_`[Computers and Intractability: A Guide to the Theory of NP-Completeness`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Computers_and_Intractability:_A_Guide_to_the_Theory_of_NP-Completeness]`_`f. W.H. Freeman. `F33f`_`[ISBN`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=ISBN_(identifier)]`_`f 0-7167-1045-5. A2.5: ND43, pg.218.
>>External links
• https://doi.org/10.7488/ds/3428 QAPLIB - A Quadratic Assignment Problem Library
• http://www.wiomax.com/team/xie/maos-qap-quadratic-assignment-problem-project-portal/ MAOS-QAP - Java-based Quadratic Assignment Problem Solver
• https://CRAN.R-project.org/package=qap - R package qap: Heuristics for the Quadratic Assignment Problem
• https://apps.microsoft.com/store/detail/qapsolver/9N7WMCFB6NZZ - Metaheuristic QAP solver for Windows 10/11
`c`F0af`_`[↑ Back to top`#top]`_`f`a